Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LfAction refactoring and area interchange target action support #1172

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

obrix
Copy link
Member

@obrix obrix commented Jan 16, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

No issue

What kind of change does this PR introduce?

Add the support of AreaInterchangeTarget action and change the implementation of LfAction.
LfAction existing design was confusing as everything was handled in the unique LfAction object.
A proper class hierarchy has been setup so as the make feature extension and maintenance easier.

What is the current behavior?

All actions implemented in the LfAction object. Created through the create method and applied through the global update connectivity method (for switch and terminal connection actions) and apply method.
Each instance of LfAction was capable of describing all kind of actions through all the available attributes but a single instance was created per iidm action.

What is the new behavior (if this is a feature change)?

All action creation and application processes are implemented in dedicated class, with common code in AbstractLfAction for all actions and additional AbstractLfBranchAction for switch and terminal connection action (they both impact topology).

Applying the action can be done through a call to the apply method or through a call to LfActionUtils.applyListOfActions. This last method, in a similar way that was done before the refactoring, apply a list of action by first applying the actions modifying topology and then the rest of the actions.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

@obrix obrix changed the title LfAction refacto and area interchange target action support [WIP] LfAction refacto and area interchange target action support Jan 16, 2025
@obrix obrix changed the title [WIP] LfAction refacto and area interchange target action support LfAction refacto and area interchange target action support Jan 20, 2025
@obrix obrix requested a review from jeandemanged January 20, 2025 08:20
@obrix
Copy link
Member Author

obrix commented Jan 21, 2025

Note for the reviewer : There was no specific rule about crashing or outputing a warning when an action cannot be applied so I kept more or less the same behavior for each action. Some of the warning / exception raising have been moved from construction to action application though.

In my opinion I would prefer to raise warning and eventually have something in the output API to query which action has been applied rather that raising an exception for potentially a single wrong action and losing all the analysis.

@obrix
Copy link
Member Author

obrix commented Jan 22, 2025

To sum up a bit, there is 4 cases of action setup that causes an exception raise :

• For TapChangerAction, if the PiModel is a SimpleModel (no tap changer on the transformer) -> throw UnsupportedOperationException
• For GeneratorAction, if we want to do something else than simply set an active power target (with absolute or relative value) : throw UnsupportedOperationException
• For HvdcAction, if ac emulation is already enabled -> throw UnsupportedOperationException
• For TerminalsConnectionAction, is a side is provided -> throw UnsupportedOperationException (only both side can be opened / closed)

Those exception are the same as before the refactoring. All other potential issue are only outputting a warning, for example a branch not found in the network for a TerminalsConnectionAction.

I also added a global warning for failing to apply an action in LfActionUtils, which might lead to a lot of warning when doing a security analysis on multiple component. So not sure we should keep that.

acParameters.getNetworkParameters().setAreaInterchangeControl(false);

LfAction lfAreaTargetAction = LfActionUtils.createLfAction(targetAction, network, acParameters.getNetworkParameters().isBreakers(), lfNetwork);
assertFalse(lfAreaTargetAction.apply(lfNetwork, null, acParameters.getNetworkParameters()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior should change very soon, after #1156 's merge.

Because of the ContingencyLoadFlowParameters extension, AIC can be performed on some post-contingency cases even if networkParameters.isAreaInterchangeControl() is false. So Area-s will now always be created, and this assertion will fail

Copy link
Member Author

@obrix obrix Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I will update if 1156 is merged before this one.

@jeandemanged jeandemanged changed the title LfAction refacto and area interchange target action support LfAction refactoring and area interchange target action support Jan 26, 2025
obrix added 16 commits January 27, 2025 14:43
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
…failure of applying an action.

Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
Signed-off-by: Bertrand Rix <[email protected]>
@obrix obrix force-pushed the area_interchange_target_action_support branch from 6267896 to 3ec6d46 Compare January 27, 2025 13:43

@Override
public boolean apply(LfNetwork network, LfContingency contingency, LfNetworkParameters networkParameters) {
LfHvdc lfHvdc = network.getHvdcById(action.getHvdcId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding here a question about the architecture change (not only specific on HVDC).
This change is not purely about architecture.
It changes also at what time static verifications (independant from the contingence) are done.
Before:

  • Where done at action creation time (once per SA run). In case of issue the action was silently ignored (now they are reproted and it is better)
    With this PR:
  • Verifications are performed for each contingence that needs them (innefficient - or can the action validity depend on the contingence ?)
  • But the result in case of inconsitency is displayed in context of the contingence via a report (good)

Can't we get the best of both world by checking the action validity at creation time, and generating the report at apply time ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions !

I can think of some scenario where the action application validity could depend on the contingency :

  • With the work currently being done on load flow parameters specific to some contingencies : might impact the succesful application of an action.
  • With some work planned on Artelys side to take into account the equivalent of "auto" action / SPS from a RAO that might be dependent on a type of contingency and then impact differently a same action done in different N-1 scenario. Maybe that's a bit early to care about that though but thats a possibility.
  • More simply an action trying to impact an equipment that was indirectly impacted by a specific contingency

I think most checks / actions application are very fast (a lookup + eventually a boolean check + a call to one or more setter). I am not too worried about that at the moment.
Some of the checks like null branch, null area could probably be removed from the apply method because they are redondant with the checkActions function though.

Maye be some checks can definitely be moved at construction time like you suggested for the generator. I'll look at it again.

}
} else {
throw new UnsupportedOperationException("Generator action on " + action.getGeneratorId() + " : configuration not supported yet.");
}
Copy link
Collaborator

@vidaldid-rte vidaldid-rte Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By checking this at apply time and not at creation time, you loose the fail fast property that existed before.

Before:
If there was an issue it was raised at launch time. User could see it immediately.
With his PR:
For a long computation, the issue may happen hours after launch time
=> User looses time
=> The user may not see the issue if lost in a large log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this can probably be moved at construction time. I will do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support area interchange actions in SA with Operator Strategies
3 participants